
public class Test3 {
    public static void swap(Mynum my1, Mynum my2) {
        int temp = my1.val;
        my1.val = my2.val;
        my2.val = temp;
    }
    public static void main(String[] args) {
        Mynum mynum1 = new Mynum();
        mynum1.val = 10;
        Mynum mynum2 = new Mynum();
        mynum2.val = 20;
        swap(mynum1,mynum2);
        System.out.println(mynum1.val + " " + mynum2.val);

        /*
        转换两数的值
        int temp = mynum1.val;
        mynum1.val = mynum2.val;
        mynum2.val = temp;
        System.out.println(mynum1.val + " " + mynum2.val);*/

        /*
        这个方法不能进行值转换
        Test3.swap(mynum1.val,mynum2.val);
        System.out.println(mynum1.val + " " + mynum2.val);
        public static void swap(int a, int b) {
            int temp = a;
            a = b;
            b = temp;
        }*/



    }
}
class Mynum{
    public int val;

}
